﻿using System;
using System.Collections;
using System.Web;
using System.Text;
using System.Collections.Generic;
using Chenxin.Lib.Utility;

public partial class CustomerInfoAdd : PageBase
{
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            //初始化操作区域
            initContext();
        }
        catch (Exception ex)
        {
            Response.Redirect("/errorpage.aspx?msg=" + ex.Message);
        }
    }

    //初始化操作区域
    private void initContext()
    {
        //客源ID
        string customerId = Request.QueryString["customerid"];
        //更新类型
        string updateType = Request.QueryString["infoclass"];
        //基本信息
        Chenxin.Lib.House.Entity.Customer_BaseInfo entBaseInfo = null;
        //需求信息
        Chenxin.Lib.House.Entity.Customer_DemandInfo entDemandInfo = null;

        if (!string.IsNullOrEmpty(customerId))
        {
            //CustomerId.Value = customerId;
            if ("baseInfo".Equals(updateType))
            {
                entBaseInfo = Chenxin.Lib.House.BLL.Custom_Info.GetCustomBaseInfo(customerId);
                setCustomerBaseInfo();
                hidBaseInfo.Value = JsonHelp.Convert2Json(entBaseInfo).Replace(",\"", ",\"CustomerInfo_").Replace("{\"", "{\"CustomerInfo_");
            }
            if ("demandInfo".Equals(updateType))
            {
                List<Chenxin.Lib.House.Entity.Customer_DemandInfo> list = Chenxin.Lib.House.BLL.Custom_Info.GetCustomerDemandInfo(customerId);
                if (list == null)
                {
                    Response.Redirect("/errorpage.aspx?msg=客需信息不存在");
                }
                entDemandInfo = list[0];
                setCustomerDemandInfo(entDemandInfo.DemandKind.Value, entDemandInfo.DemandType.Value, entDemandInfo.CustomerName);
                string strDemandInfo = JsonHelp.Convert2Json(entDemandInfo).Replace(",\"", ",\"DemandInfo_").Replace("{\"", "{\"DemandInfo_");
                string strVal = entDemandInfo.DemandKind.Value.ToString() + entDemandInfo.DemandType.Value.ToString();
                if (strVal == "1010")
                {
                    strDemandInfo = strDemandInfo.Replace("DemandInfo_DemandStyle_Room", "divBuyHouseRoom");
                    strDemandInfo = strDemandInfo.Replace("DemandInfo_DemandStyle_Hall", "divBuyHouseHall");
                    strDemandInfo = strDemandInfo.Replace("DemandInfo_DemandStyle_Toilet", "divBuyHouseToilet");
                }
                else if (strVal == "2010")
                {
                    strDemandInfo = strDemandInfo.Replace("DemandInfo_DemandStyle_Room", "divRentHouseRoom");
                    strDemandInfo = strDemandInfo.Replace("DemandInfo_DemandStyle_Hall", "divRentHouseHall");
                    strDemandInfo = strDemandInfo.Replace("DemandInfo_DemandStyle_Toilet", "divRentHouseToilet");
                }
                hidDemandInfo.Value = strDemandInfo;
            }
            if (entBaseInfo == null && entDemandInfo == null)
            {
                Response.Redirect("/errorpage.aspx?msg=客源信息不存在");
            }
        }
        else
        {
            //客户基本信息
            setCustomerBaseInfo();
            //客户需求信息
            setCustomerDemandInfo(10, 10);
            //设置显示信息
            int CntOfLimit = chkLimitOfCustomerCnt();
            if (CntOfLimit > 0)
            {
                lbMsg.Text = "【您已登记了" + CntOfLimit.ToString() + "条私有客户,新登记的客户需求将被公开到本部门共享区域中。若不希望公开该需求，请先将其他客户需求公开至共享区域】";
            }
        }
    }

    //设定基本信息
    private void setCustomerBaseInfo()
    {
        StringBuilder strHtml = new StringBuilder();
        strHtml.Append("<table width='100%' border='0' cellpadding='0' cellspacing='0' class='tabsorternew' style='table-layout: auto;'>");
        strHtml.Append("          <tr>");
        strHtml.Append("        <td  style='text-align:right; width:150px;'>客户姓名<span class='isfilled'>*</span>：</td>");
        strHtml.Append("        <td>");
        strHtml.Append("            <input type='text' size='30' maxlength=20 style='width: 150px;'  value='' class='inputbox_n fl' id='txtCustomerName' name='CustomerInfo_CustomerName'/>");
        strHtml.Append("            <div id='txtCustomerNameTip' style='float: left; margin-left: 5px; width: 120px; height: 26px; line-height: 26px; text-align: left;' class='fl'></div>");
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>性别<span class='isfilled'>*</span>：</td>");
        strHtml.Append("        <td>");
        strHtml.Append("            <input type='radio' id='radMale' name='CustomerInfo_Sex' value='10' checked='checked' />男");
        strHtml.Append("            <input type='radio' id='radFemale' name='CustomerInfo_Sex' value='20' />女");
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>手机号码：<span class='isfilled'></span></td>");
        strHtml.Append("        <td>");
        strHtml.Append("            <input type='text' size='30' style='width: 150px;' value='' class='inputbox_n fl' id='txtMobile' name='CustomerInfo_Mobile'/>");
        strHtml.Append("            <div id='txtMobileTip' style='float: left; margin-left: 5px; width: auto; height: 26px; line-height: 26px; text-align: left;' class='fl'></div>");
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>联系电话：<span class='isfilled'></span></td>");
        strHtml.Append("        <td>");
        strHtml.Append("            <input type='text' size='30' style='width: 150px;' value='' class='inputbox_n fl' id='txtPhone' name='CustomerInfo_Phone' maxlength='50'/>");
        strHtml.Append("            <div id='txtPhoneTip' style='float: left; margin-left: 5px; width: 300px; height: 26px; line-height: 26px; text-align: left;' class='fl'></div>");
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>国籍<span class='isfilled'>*</span>：<span class='isfilled'></span></td>");
        strHtml.Append("        <td>");
        strHtml.Append("            <div style='z-index: 907; margin-right: 5px;' id='CustomerInfo_Nationality' class='SelectWrapSingle'></div>");
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>证件类型：<span class='isfilled'></span></td>");
        strHtml.Append("        <td>");
        strHtml.Append("            <div style='z-index: 904; margin-right: 5px;' id='CustomerInfo_CertificateType' class='SelectWrapSingle'></div>");
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>证件号码：<span class='isfilled'></span></td>");
        strHtml.Append("        <td>");
        strHtml.Append("           <input type='text' size='30' style='width: 150px;' value='' class='inputbox_n fl' id='txtCertificateNo' name='CustomerInfo_CertificateNo'/>");
        strHtml.Append("           <div id='txtCertificateNoTip' style='float: left; margin-left: 5px; width: 120px; height: 26px; line-height: 26px; text-align: left;' class='fl'></div>");
        strHtml.Append("         </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>联系地址：<span class='isfilled'></span></td>");
        strHtml.Append("        <td><input type='text' size='30'  maxlength=100 style='width: 500px;' value='' class='inputbox_n fl' id='txtAddress' name='CustomerInfo_Address'/></td>");
        strHtml.Append("    </tr>");
        strHtml.Append("</table>");

        ltBaseInfo.Text = strHtml.ToString();
    }

    //设定需求信息
    private void setCustomerDemandInfo(int DemandKind, int DemandType)
    {
        setCustomerDemandInfo(DemandKind, DemandType, "");
    }

    //设定需求信息
    private void setCustomerDemandInfo(int DemandKind, int DemandType, string CustomerName)
    {
        StringBuilder strHtml = new System.Text.StringBuilder();
        string strJudge = DemandKind.ToString() + DemandType.ToString();

        bool isAllowPub = Chenxin.Lib.House.BLL.Custom_Info.isAllowPubDemand(CurrentUserInfo.DepartId);

        if (CustomerName != "")
        {
            strHtml.Append(getHtmlOfCustomerNm(CustomerName));
            //编辑客需时公开级别不可编辑
            isAllowPub = false;
        }

        //需求类型
        strHtml.Append(getHtmlOfDemandType());

        strHtml.Append("<div id='divDemandDetailInfo'>");
        //求购 住房
        strHtml.Append(getHtmlOfBuyHouse(strJudge));
        //求购 商铺
        strHtml.Append(getHtmlOfBuyShop(strJudge));
        //求购 办公楼
        strHtml.Append(getHtmlOfBuyOffice(strJudge));
        //求租 住房
        strHtml.Append(getHtmlOfRentHouse(strJudge));
        //求租 商铺
        strHtml.Append(getHtmlOfRentShop(strJudge));
        //求租 办公楼
        strHtml.Append(getHtmlOfRentOffice(strJudge));
        strHtml.Append("</div>");
        //公开级别
        strHtml.Append(getHtmlOfAllowPub(isAllowPub));

        ltCustomerInfo.Text = strHtml.ToString();
    }

    //生成CheckBox列表
    private string crtCheckBoxGroup(string ItemKey,string ChkName)
    {
        StringBuilder strHtml = new StringBuilder();
        Chenxin.Lib.House.BLL.DataDictionary bllDataDic = new Chenxin.Lib.House.BLL.DataDictionary();
        List<Chenxin.Lib.House.Entity.DataDictionary> lsDataDic = new List<Chenxin.Lib.House.Entity.DataDictionary>();
        if ("System.Region".Equals(ItemKey))
        {
            lsDataDic = bllDataDic.GetDicList(ItemKey, CurrentUserInfo.CityId);
        }
        else {
            lsDataDic = bllDataDic.GetDicList(ItemKey, CurrentUserInfo.CityId, CurrentUserInfo.CompanyId);
        } 
        //为空判断
        if (lsDataDic.Count > 0)
        {
            //列表循环
            for (int idxCnt = 0; idxCnt < lsDataDic.Count; idxCnt++)
            {
                strHtml.Append("<input type='checkbox' name='" + ChkName + "' value='" + lsDataDic[idxCnt].ItemValue + "' /> ");
                strHtml.Append(lsDataDic[idxCnt].ItemValue + " ");
            }
        }
        return strHtml.ToString();
    }

    //客户姓名
    private string getHtmlOfCustomerNm(string CustomerName)
    {
        StringBuilder strHtml = new StringBuilder();
        strHtml.Append("<table width='100%' border='0' cellspacing='0' cellpadding='0'  class='tabsorternew' id='tbAllowPub'>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td  style='text-align:right; width:150px;'>客户姓名：</td>");
        strHtml.Append("        <td>");
        strHtml.Append(CustomerName);
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("</table>");
        return strHtml.ToString();
    }

    //需求类型
    private string  getHtmlOfDemandType()
    {

        StringBuilder strHtml = new StringBuilder();

        strHtml.Append("<div  id='divDemandType'>");
        strHtml.Append("<input type=hidden name='DemandInfo_DemandId' />");
        strHtml.Append("    <table width='100%' border='0' cellspacing='0' cellpadding='0' class='tabsorternew'>");
        strHtml.Append("        <tr>");
        strHtml.Append("            <td style='text-align:right; width:150px;'>客户类型<span class='isfilled'>*</span>：</td>");
        strHtml.Append("            <td>");
        strHtml.Append("                <input type='radio' id='radBuy' name='DemandInfo_DemandKind' value='10'  checked='checked' />求购");
        strHtml.Append("                <input type='radio' id='radRental' name='DemandInfo_DemandKind' value='20' />求租");
        strHtml.Append("            </td>");
        strHtml.Append("        </tr>");
        strHtml.Append("        <tr>");
        strHtml.Append("            <td style='text-align:right;'>需求类型：<span class='isfilled'></span></td>");
        strHtml.Append("            <td>");
        strHtml.Append("                <input type='radio' id='radHouse' name='DemandInfo_DemandType' value='10' checked='checked' />住宅");
        strHtml.Append("                <input type='radio' id='radShop' name='DemandInfo_DemandType' value='20' />商铺");
        strHtml.Append("                <input type='radio' id='radOffice' name='DemandInfo_DemandType' value='30' />办公");
        strHtml.Append("            </td>");
        strHtml.Append("        </tr>");
        strHtml.Append("    </table>");
        strHtml.Append("</div>");
        strHtml.Append("<div  class='clear' style='height:10px'></div>");

        return strHtml.ToString();
    }

    //求购 住房
    private string getHtmlOfBuyHouse(string strJudge)
    {
        StringBuilder strHtml = new StringBuilder();

        if (strJudge == "1010")
        {
            strHtml.Append("<table width='100%' border='0' cellspacing='0' cellpadding='0'  class='tabsorternew' id='tbBuyHouse'>");
        }
        else
        {
            strHtml.Append("<table width='100%' border='0' cellspacing='0' cellpadding='0'  class='tabsorternew' id='tbBuyHouse'style='display:none'>");
        }
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right; width:150px;'>购房时间：</td>");
        strHtml.Append("        <td>");
        strHtml.Append(crtCheckBoxGroup("Customer.Demand.BuyTime", "DemandInfo_HouseBuyTime"));
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>欲购区域：</td>");
        strHtml.Append("        <td>");
        strHtml.Append(crtCheckBoxGroup("System.Region", "DemandInfo_DemandZone"));
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>物业类型：</td>");
        strHtml.Append("        <td>");
        strHtml.Append(crtCheckBoxGroup("Customer.Demand.HouseType", "DemandInfo_DemandBuilding"));
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>欲购面积(㎡)：</td>");
        strHtml.Append("        <td>");
        strHtml.Append(crtCheckBoxGroup("Customer.Demand.HouseArea", "DemandInfo_DemandArea"));
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>欲购单价(元/㎡)：</td>");
        strHtml.Append("        <td>");
        strHtml.Append(crtCheckBoxGroup("Customer.Demand.BuyHouseUPrice", "DemandInfo_UnitPrice"));
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>欲购总价(万元)：<br/></td>");
        strHtml.Append("        <td>");
        strHtml.Append(crtCheckBoxGroup("Customer.Demand.BuyHouseTPrice", "DemandInfo_TotalPrice"));
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>购房目的：</td>");
        strHtml.Append("        <td>");
        strHtml.Append(crtCheckBoxGroup("Customer.Demand.BuyHouseUse", "DemandInfo_HouseUse"));
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>考虑因素：</td>");
        strHtml.Append("        <td>");
        strHtml.Append(crtCheckBoxGroup("Customer.Demand.HouseConsider", "DemandInfo_Consider"));
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>服务需求：</td>");
        strHtml.Append("        <td>");
        strHtml.Append(crtCheckBoxGroup("Customer.Demand.ServiceDemand", "DemandInfo_ServiceDemand"));
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>装修情况：</td>");
        strHtml.Append("        <td>");
        strHtml.Append(crtCheckBoxGroup("Customer.Demand.Fitment", "DemandInfo_Fitment"));
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>房间类型需求：</td>");
        strHtml.Append("        <td>");
        strHtml.Append("            <div style='z-index: 904; margin-right: 5px;' id='divBuyHouseRoom' class='SelectWrapSingle'></div>");
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>厅房类型需求：</td>");
        strHtml.Append("        <td>");
        strHtml.Append("            <div style='z-index: 903; margin-right: 5px;' id='divBuyHouseHall' class='SelectWrapSingle'></div>");
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>卫生间类型需求：</td>");
        strHtml.Append("        <td>");
        strHtml.Append("            <div style='z-index: 902; margin-right: 5px;' id='divBuyHouseToilet' class='SelectWrapSingle'></div>");
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>特殊要求：</td>");
        strHtml.Append("        <td>");
        strHtml.Append(crtCheckBoxGroup("Customer.Demand.SpecialDemand", "DemandInfo_SpecialDemand"));
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>备注：</td>");
        strHtml.Append("        <td>");
        strHtml.Append("            <textarea id='buyHouseRemark' name='DemandInfo_Remark' cols='80' rows='2' class='textarea_n' style=' height:30px;padding:5px;'></textarea>");
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("</table>");

        return strHtml.ToString();
    }

    //求购 商铺
    private string getHtmlOfBuyShop(string strJudge)
    {
        StringBuilder strHtml = new StringBuilder();

        if (strJudge == "1020")
        {
            strHtml.Append("<table width='100%' border='0' cellspacing='0' cellpadding='0'  class='tabsorternew' id='tbBuyShop'>");
        }
        else
        {
            strHtml.Append("<table width='100%' border='0' cellspacing='0' cellpadding='0'  class='tabsorternew' id='tbBuyShop' style='display:none'>");
        }
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right; width:150px;'>购房时间：</td>");
        strHtml.Append("        <td>");
        strHtml.Append(crtCheckBoxGroup("Customer.Demand.BuyTime", "DemandInfo_HouseBuyTime"));
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>欲购区域：</td>");
        strHtml.Append("        <td>");
        strHtml.Append(crtCheckBoxGroup("System.Region", "DemandInfo_DemandZone"));
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>商铺类型：</td>");
        strHtml.Append("        <td>");
        strHtml.Append(crtCheckBoxGroup("Customer.Demand.ShopType", "DemandInfo_DemandBuilding"));
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>欲购面积(㎡)：</td>");
        strHtml.Append("        <td>");
        strHtml.Append(crtCheckBoxGroup("Customer.Demand.ShopArea", "DemandInfo_DemandArea"));
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>欲购单价(元/㎡)：</td>");
        strHtml.Append("        <td>");
        strHtml.Append(crtCheckBoxGroup("Customer.Demand.BuyShopUPrice", "DemandInfo_UnitPrice"));
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>欲购总价(万元)：<br/></td>");
        strHtml.Append("        <td>");
        strHtml.Append(crtCheckBoxGroup("Customer.Demand.BuyShopTPrice", "DemandInfo_TotalPrice"));
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>购买用途：</td>");
        strHtml.Append("        <td>");
        strHtml.Append(crtCheckBoxGroup("Customer.Demand.ShopUse", "DemandInfo_HouseUse"));
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>考虑因素：</td>");
        strHtml.Append("        <td>");
        strHtml.Append(crtCheckBoxGroup("Customer.Demand.ShopConsider", "DemandInfo_Consider"));
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>期望回报率：</td>");
        strHtml.Append("        <td>");
        strHtml.Append(crtCheckBoxGroup("Customer.Demand.ReturnRate", "DemandInfo_ReturnRate"));
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>备注：</td>");
        strHtml.Append("        <td>");
        strHtml.Append("            <textarea id='buyShopRemark' name='DemandInfo_Remark' cols='80' rows='2' class='textarea_n' style=' height:30px;padding:5px;'></textarea>");
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("</table>");

        return strHtml.ToString();
    }

    //求购 办公
    private string getHtmlOfBuyOffice(string strJudge)
    {
        StringBuilder strHtml = new StringBuilder();
        if (strJudge == "1030")
        {
            strHtml.Append("<table width='100%' border='0' cellspacing='0' cellpadding='0'  class='tabsorternew' id='tbBuyOffice'>");
        }
        else
        {
            strHtml.Append("<table width='100%' border='0' cellspacing='0' cellpadding='0'  class='tabsorternew' id='tbBuyOffice' style='display:none'>");
        }
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right; width:150px;'>购房时间：</td>");
        strHtml.Append("        <td>");
        strHtml.Append(crtCheckBoxGroup("Customer.Demand.BuyTime", "DemandInfo_HouseBuyTime"));
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>欲购区域：</td>");
        strHtml.Append("        <td>");
        strHtml.Append(crtCheckBoxGroup("System.Region", "DemandInfo_DemandZone"));
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>类型：</td>");
        strHtml.Append("        <td>");
        strHtml.Append(crtCheckBoxGroup("Customer.Demand.OfficeType", "DemandInfo_DemandBuilding"));
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>欲购面积(㎡)：</td>");
        strHtml.Append("        <td>");
        strHtml.Append(crtCheckBoxGroup("Customer.Demand.OfficeArea", "DemandInfo_DemandArea"));
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>欲购单价(元/㎡)：</td>");
        strHtml.Append("        <td>");
        strHtml.Append(crtCheckBoxGroup("Customer.Demand.BuyOfficeUPrice", "DemandInfo_UnitPrice"));
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>欲购总价(万元)：<br/></td>");
        strHtml.Append("        <td>");
        strHtml.Append(crtCheckBoxGroup("Customer.Demand.BuyOfficeTPrice", "DemandInfo_TotalPrice"));
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>考虑因素：</td>");
        strHtml.Append("        <td>");
        strHtml.Append(crtCheckBoxGroup("Customer.Demand.OfficeConsider", "DemandInfo_Consider"));
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>期望回报率：</td>");
        strHtml.Append("        <td>");
        strHtml.Append(crtCheckBoxGroup("Customer.Demand.ReturnRate", "DemandInfo_ReturnRate"));
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>备注：</td>");
        strHtml.Append("        <td>");
        strHtml.Append("           <textarea id='buyOfficeRemark' name='DemandInfo_Remark' cols='80' rows='2' class='textarea_n' style=' height:30px;padding:5px;'></textarea>");
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("</table>");

        return strHtml.ToString();
    }

    //求租 住房
    private string getHtmlOfRentHouse(string strJudge)
    {
        StringBuilder strHtml = new StringBuilder();
        if (strJudge == "2010")
        {
            strHtml.Append("<table width='100%' border='0' cellspacing='0' cellpadding='0'  class='tabsorternew' id='tbRentHouse'>");
        }
        else
        {
            strHtml.Append("<table width='100%' border='0' cellspacing='0' cellpadding='0'  class='tabsorternew' id='tbRentHouse' style='display:none'>");
        }
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right; width:150px;'>租房时间：</td>");
        strHtml.Append("        <td>");
        strHtml.Append(crtCheckBoxGroup("Customer.Demand.BuyTime", "DemandInfo_HouseBuyTime"));
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>欲租区域：</td>");
        strHtml.Append("        <td>");
        strHtml.Append(crtCheckBoxGroup("System.Region", "DemandInfo_DemandZone"));
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>物业类型：</td>");
        strHtml.Append("        <td>");
        strHtml.Append(crtCheckBoxGroup("Customer.Demand.HouseType", "DemandInfo_DemandBuilding"));
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>欲租面积(㎡)：</td>");
        strHtml.Append("        <td>");
        strHtml.Append(crtCheckBoxGroup("Customer.Demand.HouseArea", "DemandInfo_DemandArea"));
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>租房目的：</td>");
        strHtml.Append("        <td>");
        strHtml.Append(crtCheckBoxGroup("Customer.Demand.RentHouseUse", "DemandInfo_HouseUse"));
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>装修情况：</td>");
        strHtml.Append("        <td>");
        strHtml.Append(crtCheckBoxGroup("Customer.Demand.Fitment", "DemandInfo_Fitment"));
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>房间类型需求：</td>");
        strHtml.Append("        <td>");
        strHtml.Append("            <div style='z-index: 904; margin-right: 5px;' id='divRentHouseRoom' class='SelectWrapSingle'></div>");
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>厅房类型需求：</td>");
        strHtml.Append("        <td>");
        strHtml.Append("            <div style='z-index: 903; margin-right: 5px;' id='divRentHouseHall' class='SelectWrapSingle'></div>");
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>卫生间类型需求：</td>");
        strHtml.Append("        <td>");
        strHtml.Append("            <div style='z-index: 902; margin-right: 5px;' id='divRentHouseToilet' class='SelectWrapSingle'></div>");
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>欲租单价(元/月)：</td>");
        strHtml.Append("        <td>");
        strHtml.Append(crtCheckBoxGroup("Customer.Demand.RentHouseUPrice", "DemandInfo_UnitPrice"));
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>特殊要求：</td>");
        strHtml.Append("        <td>");
        strHtml.Append(crtCheckBoxGroup("Customer.Demand.SpecialDemand", "DemandInfo_SpecialDemand"));
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>备注：</td>");
        strHtml.Append("        <td>");
        strHtml.Append("            <textarea id='rentHouseRemark' name='DemandInfo_Remark' cols='80' rows='2' class='textarea_n' style=' height:30px;padding:5px;'></textarea>");
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("</table>");

        return strHtml.ToString();
    }

    //求租 商铺
    private string getHtmlOfRentShop(string strJudge)
    {
        StringBuilder strHtml = new StringBuilder();
        if (strJudge == "2020")
        {
            strHtml.Append("<table width='100%' border='0' cellspacing='0' cellpadding='0'  class='tabsorternew' id='tbRentShop'>");
        }
        else
        {
            strHtml.Append("<table width='100%' border='0' cellspacing='0' cellpadding='0'  class='tabsorternew' id='tbRentShop' style='display:none'>");
        }
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right; width:150px;'>租房时间：</td>");
        strHtml.Append("        <td>");
        strHtml.Append(crtCheckBoxGroup("Customer.Demand.BuyTime", "DemandInfo_HouseBuyTime"));
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>欲租区域：</td>");
        strHtml.Append("        <td>");
        strHtml.Append(crtCheckBoxGroup("System.Region", "DemandInfo_DemandZone"));
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>商铺类型：</td>");
        strHtml.Append("        <td>");
        strHtml.Append(crtCheckBoxGroup("Customer.Demand.ShopType", "DemandInfo_DemandBuilding"));
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>欲租面积(㎡)：</td>");
        strHtml.Append("        <td>");
        strHtml.Append(crtCheckBoxGroup("Customer.Demand.ShopArea", "DemandInfo_DemandArea"));
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>欲租单价(元/月)：</td>");
        strHtml.Append("        <td>");
        strHtml.Append(crtCheckBoxGroup("Customer.Demand.RentShopUPrice", "DemandInfo_UnitPrice"));
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>租房用途：</td>");
        strHtml.Append("        <td>");
        strHtml.Append(crtCheckBoxGroup("Customer.Demand.ShopUse", "DemandInfo_HouseUse"));
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>考虑因素：</td>");
        strHtml.Append("        <td>");
        strHtml.Append(crtCheckBoxGroup("Customer.Demand.ShopConsider", "DemandInfo_Consider"));
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>期望回报率：</td>");
        strHtml.Append("        <td>");
        strHtml.Append(crtCheckBoxGroup("Customer.Demand.ReturnRate", "DemandInfo_ReturnRate"));
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>备注：</td>");
        strHtml.Append("        <td>");
        strHtml.Append("           <textarea id='rentShopRemark' name='DemandInfo_Remark' cols='80' rows='2' class='textarea_n' style=' height:30px;padding:5px;'></textarea>");
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("</table>");

        return strHtml.ToString();
    }

    //求租 办公
    private string getHtmlOfRentOffice(string strJudge)
    {
        StringBuilder strHtml = new StringBuilder();
        if (strJudge == "2030")
        {
            strHtml.Append("<table width='100%' border='0' cellspacing='0' cellpadding='0'  class='tabsorternew' id='tbRentOffice'>");
        }
        else
        {
            strHtml.Append("<table width='100%' border='0' cellspacing='0' cellpadding='0'  class='tabsorternew' id='tbRentOffice' style='display:none'>");
        }
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right; width:150px;'>租房时间：</td>");
        strHtml.Append("        <td>");
        strHtml.Append(crtCheckBoxGroup("Customer.Demand.BuyTime", "DemandInfo_HouseBuyTime"));
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>欲租区域：</td>");
        strHtml.Append("        <td>");
        strHtml.Append(crtCheckBoxGroup("System.Region", "DemandInfo_DemandZone"));
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>类型：</td>");
        strHtml.Append("        <td>");
        strHtml.Append(crtCheckBoxGroup("Customer.Demand.OfficeType", "DemandInfo_DemandBuilding"));
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>欲租面积(㎡)：</td>");
        strHtml.Append("        <td>");
        strHtml.Append(crtCheckBoxGroup("Customer.Demand.OfficeArea", "DemandInfo_DemandArea"));
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>欲租单价(元/月)：</td>");
        strHtml.Append("        <td>");
        strHtml.Append(crtCheckBoxGroup("Customer.Demand.RentOfficeUPrice", "DemandInfo_UnitPrice"));
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("        <td style='text-align:right;'>考虑因素：</td>");
        strHtml.Append("        <td>");
        strHtml.Append(crtCheckBoxGroup("Customer.Demand.OfficeConsider", "DemandInfo_Consider"));
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>期望回报率：</td>");
        strHtml.Append("        <td>");
        strHtml.Append(crtCheckBoxGroup("Customer.Demand.ReturnRate", "DemandInfo_ReturnRate"));
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("    <tr>");
        strHtml.Append("        <td style='text-align:right;'>备注：</td>");
        strHtml.Append("        <td>");
        strHtml.Append("           <textarea id='buyOfficeRemark' name='DemandInfo_Remark' cols='80' rows='2' class='textarea_n' style=' height:30px;padding:5px;'></textarea>");
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("</table>");

        return strHtml.ToString();
    }

    //公私的判断
    private string getHtmlOfAllowPub(bool isAllowPub)
    {
        StringBuilder strHtml = new StringBuilder();
        if (isAllowPub)
        {
            strHtml.Append("<table width='100%' border='0' cellspacing='0' cellpadding='0'  class='tabsorternew' id='tbAllowPub'>");
        }
        else
        {
            strHtml.Append("<table width='100%' border='0' cellspacing='0' cellpadding='0'  class='tabsorternew' id='tbAllowPub' style='display:none'>");
        }
        strHtml.Append("    <tr>");
        strHtml.Append("        <td  style='text-align:right; width:150px;'>客需类型：</td>");
        strHtml.Append("        <td>");
        strHtml.Append("                <input type='radio' name='DemandInfo_PubLevel' value='0' checked='checked' />私有");
        strHtml.Append("                <input type='radio' name='DemandInfo_PubLevel' value='10' />公司级公有");
        strHtml.Append("                <input type='radio' name='DemandInfo_PubLevel' value='20' />跨部级公有");
        strHtml.Append("                <input type='radio' name='DemandInfo_PubLevel' value='30' />本部级公有");
        strHtml.Append("        </td>");
        strHtml.Append("    </tr>");
        strHtml.Append("</table>");
        return strHtml.ToString();    
    }

    //检查需求客户数量上限
    private int chkLimitOfCustomerCnt()
    {
        int iRet = 0;
        //需求客户数量上限
        int iLimitCntOfCustomer = Chenxin.Lib.House.BLL.Custom_Info.getCntOfCustomerLimit(CurrentUserInfo.DepartId);
        if (iLimitCntOfCustomer > 0)
        {
            Chenxin.Lib.House.BLL.Customer_BaseInfo bllBaseInfo = new Chenxin.Lib.House.BLL.Customer_BaseInfo();
            //当前用户所有需求客户数量
            int iCntOfCustomer = bllBaseInfo.GetCntOfCustomer(CurrentUserInfo.UserId);
            //超过上限
            if (iCntOfCustomer >= iLimitCntOfCustomer)
            {
                iRet = iCntOfCustomer;
            }
        }
        return iRet;
    }
}
